package com._520it.crm.web.controller;

import com._520it.crm.domain.Premium;
import com._520it.crm.page.PageResult;
import com._520it.crm.query.PremiumQueryObject;
import com._520it.crm.service.IPremiumService;
import com._520it.crm.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by 呆 on 2017/10/3.
 */
@Controller
@RequestMapping("/premium")
public class PremiumController {
    @Autowired
    private IPremiumService premiumService;
    @RequestMapping("")
    public String index(){
        return "premium";
    }

    @RequestMapping("/list")
    @ResponseBody
    public PageResult list(PremiumQueryObject qo){
         return premiumService.query(qo);
    }
    @RequestMapping("/savePremium")
    @ResponseBody
    public AjaxResult savePremium(Premium premium){
        AjaxResult result = null;
        try {
            premiumService.insert(premium);
            result = new AjaxResult("保存成功");
        } catch (Exception e) {
            e.printStackTrace();
            result = new AjaxResult(false,"保存失败");
        }
        return result;
    }
}
